<template>
	<view class="ys">
		<view class="detail">
			<view class="title">
				告警信息
			</view>
			<view class="time">
				{{info.alarmTime}}
			</view>
			<view class="box">
				<view class="infoli">
					<view class="left">
						事件类型
					</view>
					<view class="right">
						{{eventList[info.eventType]}}
					</view>
				</view>
				<view class="infoli">
					<view class="left">
						房屋名
					</view>
					<view class="right">
						{{info.houseName}}
					</view>
				</view>
				<view class="infoli">
					<view class="left">
						详细地址
					</view>
					<view class="right">
						{{info.houseStandardAddress}}
					</view>
				</view>
				<view class="infoli">
					<view class="left">
						报警内容
					</view>
					<view class="right">
						{{info.content}}
					</view>
				</view>
				<view class="infoli">
					<view class="left">
						处理状态
					</view>
					<view class="right status">
						<text v-if="info.stat == 2">已处理</text>
						<text v-else>未处理</text>
					</view>
				</view>
			</view>
			<view class="box">
				<view class="infoli">
					<view class="left">
						房东姓名
					</view>
					<view class="right">
						{{info.ownerName}}
					</view>
				</view>
				<view class="infoli">
					<view class="left">
						联系方式
					</view>
					<view class="right">
						{{info.ownerMobile}}
					</view>
				</view>
			</view>
			<view class="box" v-if="info.stat == 2">
				<view class="infoli">
					<view class="left">
						处理人姓名
					</view>
					<view class="right">
						{{info.handleUserName}}
					</view>
				</view>
				<view class="infoli">
					<view class="left">
						处理时间
					</view>
					<view class="right">
						{{info.handleTime}}
					</view>
				</view>
				<view class="infoli">
					<view class="left">
						处理备注
					</view>
					<view class="right">
						{{info.handleDesc}}
					</view>
				</view>
			</view>
			<view class="box" v-if="info.stat !=2">
				<view class="infoli textareabox">
					<view class="left">
						处理备注
					</view>
					<textarea v-model="handleDesc" placeholder="请输入备注"></textarea>
				</view>

			</view>
		</view>
		<view class="btn" v-if="info.stat !=2">
			<button :loading="loading" :disabled="loading" @click="submit">提交</button>
		</view>
	</view>
</template>

<script>
	import {
		alarmdetail,
		alarmhandle
	} from "@/api/api.js"
	export default {
		data() {
			return {
				id: '',
				handleDesc: '',
				info: [],
				loading: false,
				eventList: {
					1: '人脸抓拍',
					2: '人脸识别',
					3: '电动车'
				}
			}
		},
		onLoad(e) {
			if (e.id) {
				this.id = e.id
				this.alarmdetail()
			}
		},
		methods: {
			submit() {
				if (this.handleDesc == '') return uni.$showMsg('请输入备注')
				alarmhandle({
					handleDesc: this.handleDesc,
					id: this.id
				}).then(res => {
					uni.$showMsg(res.msg)
					if (res.code == 200) {
						setTimeout(() => {
							uni.navigateBack()
						}, 800)
					}
				})
			},
			alarmdetail() {
				alarmdetail({
					id: this.id
				}).then(res => {
					if (res.code == 200) {
						this.info = res.data
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #f2f2f2;
		padding-top: 10px;
	}

	.btn {
		margin-top: 20px;

		button {
			width: 96%;
			margin: 0 auto;
			box-sizing: border-box;
			background: #ff9365;
			color: #fff;
			font-size: 14px;
		}
	}

	.detail {
		width: 96%;
		margin: 0 auto;
		background: #fff;
		padding: 15px;
		box-sizing: border-box;
		border-radius: 8px;

		.box {
			border-bottom: 1px solid #eee;
			padding: 10px 0;

			&:last-child {
				border-bottom: 0;
			}

			.infoli {
				display: flex;
				font-size: 14px;
				padding: 5px 0;

				.left {
					width: 100px;
					color: #777;
				}

				.right {
					width: calc(100% - 100px);

					&.status {
						color: #aa0000;
					}
				}

				&.textareabox {
					flex-direction: column;

					textarea {
						width: 100%;
						border-radius: 5px;
						margin-top: 5px;
						font-size: 14px;
						background: #f2f2f2;
						padding: 10px;
						box-sizing: border-box;
					}
				}
			}
		}

		.title {
			font-weight: bold;
			text-align: center;
			letter-spacing: 1px;
			font-size: 17px;
		}

		.time {
			font-size: 12px;
			text-align: center;
			color: #333;
			margin-bottom: 10px;
			margin-top: 5px;
		}
	}
</style>